#!/bin/bash
set -e;
source ../../pi.vars;

rm -rf /tmp/pivpn;
git clone ${github_proxy}https://github.com/pivpn/pivpn.git /tmp/pivpn;rm -rf /tmp/pivpn/.git*;

sudo -s /bin/bash -c "cd /tmp/pivpn/auto_install/;bash install.sh;"


echo "do you want init"
read -t 10 -p "y/n: " is_init;

if [[ "${is_init}" == "y" ]];then
    sudo cp init_openvpn_config.sh /opt/pivpn/update_openvpn_config.sh;
    sudo chmod 755 /opt/pivpn/update_openvpn_config.sh;
    sudo /opt/pivpn/update_openvpn_config.sh
fi